Ctags For Markdown Tags

Meow King December 02, 2023 Updated: December 02, 2023 #ctags #markdown #emacs

Ctags file .ctags at project root:
How to define this

--langdef=MarkdownTAG
--map-MarkdownTAG=.md
--kinddef-MarkdownTAG=t,tag,tag

--_tabledef-MarkdownTAG=toplevel
--_tabledef-MarkdownTAG=tags

--_mtable-regex-MarkdownTAG=toplevel/tags\s*=//{tenter=tags}
--_mtable-regex-MarkdownTAG=toplevel/.//

--_mtable-regex-MarkdownTAG=tags/\n//{tleave}
--_mtable-regex-MarkdownTAG=tags/"([^"]+)"/\1/t/
--_mtable-regex-MarkdownTAG=tags/.//

Then you just need to run

ctags --options=.ctags -R --languages=MarkdownTAG ./content

Integration With Emacs

Vanilla Emacs's original capability

Use this command to create a etags format

ctags --options=.ctags -R --languages=MarkdownTAG ./content -e

visit-tags-table -> complete-tag

Integration with Citre

citre-edit-tags-file-recipe

ctags
-o
%TAGSFILE%
--options=.ctags
--languages=MarkdownTAG
--kinds-all=*
--fields=*
--extras=*
-R
./content

Then you can happily use completion-at-point to complete the tags.